package com.mhc.suzuki.constant;

/**
 * Created by kanon on 17/8/17.
 */
public enum ErrorCodeEnum {

    /*
     * 错误码结构: PCL+三位业务类别+三位错误码<br>
     * ===========================================<br> 100表示系统类别<br>
     * 101表示通用类别<br>
     */

    /*--------- 100开头表示系统级别错误 ---------*/
    SYS_ERROR("PCL100001", "系统内部错误"),

    /*--------- 101开头表示通用类别 ---------*/
    SUCCESS("PCL101001", "成功"),
    FAILURE("PCL101002", "失败"),
    PARAM_ERROR("PCL101003", "参数错误"),
    PARAM_EMPTY("PCL101004", "参数为空"),
    NO_MODIFY("PCL201005", "您尚未修改任何信息，内容无需更新"),
    SELECT_FAILURE("PCL201006", "查询错误"),
    GETDATA_ERROR("PCL201007", "获取数据错误"),
    ENTRY_ERROR("PCL201008", "录入错误"),
    NO_DATA("PCL1010O9", "没有数据"),
    NOT_LOGIN("PCL101010", "用户没有登录"),
    NO_AUTH("PCL101011", "没有权限"),
    PAYEE_DEALER_INFO_ERROR("PCL201016", "垫款信息为空,数据异常"),
    GPS_INFO_EMPTRY("PCL201017", "GPS编号为空，请补全资料"),
    FILL_INFOMATION_ERROR("PCL201018", "补录资料错误,数据异常"),
    BUYER_NAME_ISNULL("PCL101012", "购车人姓名为空"),
    BUYER_IDCARD_ISNULL("PCL101013", "购车人身份证为空"),
    COMMON_BUYER_NAME_ISNULL("PCL101014", "共同购车人姓名为空"),
    COMMON_BUYER_IDCARD_ISNULL("PCL101015", "共同购车人身份证为空"),
    SPONSOR_NAME_ISNULL("PCL101016", "担保人姓名为空"),
    SPONSOR_IDCARD_ISNULL("PCL101017", "担保人身份证为空"),
    SPONSOR_TOO_MORE("PCL101018", "担保人不能超过5个"),
    INSERT_OR_UPDATA_FAIL("PCL201019", "新增或者更新数据失败"),
    INSERT_OR_UPDATA_ERROR("PCL201020", "新增或者更新数据异常"),
    ANNEX_BATCH_NO_ISNULL("PCL201021", "附件批次号为空"),
    ORDER_EXIST("PCL201022", "订单已经存在,请勿重复提交"),
    ORDER_NO_ISNULL("PCL201023", "订单号为空"),
    CREDIT_ANNEX_LESS_THREE("PCL201024", "征信图片少于3张"),
    INSURANCE_INFO_TOO_MORE("PCL201025", "保险信息多余两条"),
    CARINFO_NOT_EXIST("PCL201026", "车辆信息不存在"),
    LOANINFO_TOO_MORE("PCL201027", "贷款信息多于一条"),
    ACCIDENTINFO_NOT_EXIST("PCL201028", "出险信息不存在"),

    NOTARYMORTGAGE_NOT_EXIST("PCL201030", "公证抵押记录不存在"),
    CONSTACT_NOT_EXIST("PCL201031", "合同齐全信息不存在"),
    POSTBANKCARD_NOT_EXIST("PCL201032", "寄卡信息不存在"),
    REFUNDEPOSIT_NOT_EXIST("PCL201033", "退保证金信息不存在"),
    LOANCLEAR_NOT_EXIST("PCL201034", "结清信息不存在"),
    DATA_ERROR("PCL201035", "数据有误"),
    BE_MARRIED_ERROR("PCL201036", "婚姻状态有误"),
    CUSTOMER_TOO_MORE("PCL201037", "客户信息多于一条"),
    BANK_ISNULL("PCL101038", "贷款银行为空"),
    BE_MARRIED_ISNULL("PCL101039", "婚姻状态为空"),
    CUSTOMER_IS_NULL("PCL101040", "客户不存在"),
    ORDER_MORE_THAN_ONE("PCL101041", "订单数据重复"),
    CONTACT_MORE_THAN_TWO("PCL101042", "紧急联系人多余两个"),
    IDCARD_IMAGE_TOO_LARGE("PCL101043", "身份照片不能大于1.5M"),
    DATEFORMAT_ERROR("PCL101044", "时间格式有误"),
    DATE_IS_NULL("PCL101045", "时间为空"),
    INSERT_OR_UPDATA_HOUSE_FAIL("PCL201046", "新增或者更新房产数据失败"),
    INSERT_OR_UPDATA_EMERGENCY_CONTACT_FAIL("PCL201047", "新增或者更新紧急联系人数据失败"),
    APPLY_TYPE_ISNULL("PCL201048", "审批业务类型为空"),
    IDCARD_FORMAT_ERROR("PCL101049", "身份证号格式有误"),
    PAYMENT_REQUEST_ISNULL("PCL201050", "垫款信息为空"),
    DEPT_AREA_ISNULL("PCL201051", "部门所属省份为空"),
    UPDATA_ORDER_STATUS_BANK_YET_LENDING_FAIL("PCL201052", "更新订单状态为银行已放款失败"),
    STAFF_ID_ISNULL("PCL201053", "员工id不能为空"),
    QUERY_ORDER_AUDIT_PROCESS_FAIL("PCL201054", "查询订单审核进度失败"),
    FILE_ISNULL("PCL201055", "文件不能为空"),
    FILE_UPLOAD_FAIL("PCL201056", "文件上传失败"),
    QUERY_OVERDUE_LIST_FAIL("PCL201057", "查询逾期清单列表失败"),
    QUERY_BANK_INFO_FAIL("PCL201058", "获取银行账户信息失败"),
    OVERDUE_ID_ISNULL("PCL201059", "逾期记录编号不能为空"),
    QUERY_DEBT_COLLECT_DETAIL_FAIL("PCL201060", "查找催收记录失败"),
    QUERY_TOWING_HIS_LIST_FAIL("PCL201061", "查找拖车记录失败"),
    QUERY_LAWSUIT_HIS_LIST_FAIL("PCL201062", "查找法院诉讼记录失败"),
    QUERY_OVERDUE_ORDER_LIST_FAIL("PCL201063", "查询逾期订单列表失败"),
    TEL_DEBT_COLLECT_HIS_ISNULL("PCL201064", "电催记录不能为空"),
    INSERT_TEL_DEBT_COLLECT_HIS_FAIL("PCL201065", "新增电催记录失败"),
    INSERT_LOANINFO_FAIL("PCL201066", "保存银行放款信息失败"),
    INSERT_SETTLEMENT_COST_FAIL("PCL201067", "保存费用信息失败"),
    UPDATA_WAITING_TASK_PENDING_FAIL("PCL201068", "更新外勤待办任务失败"),
    VISIT_DEBT_COLLECT_HIS_ISNULL("PCL201069", "上门催收记录不能为空"),
    INSERT_VISIT_DEBT_COLLECT_HIS_FAIL("PCL201070", "新增上门催收记录失败"),
    TOWING_HIS__ISNULL("PCL201071", "拖车记录不能为空"),
    INSERT_TOWING_HIS_FAIL("PCL201072", "新增拖车记录失败"),
    UPDATE_TOWING_HIS_FAIL("PCL201073", "修改拖车记录失败"),
    LAWSUIT_HIS_ISNULL("PCL201074", "法院诉讼记录不能为空"),
    INSERT_LAWSUIT_HIS_FAIL("PCL201075", "新增法院诉讼记录失败"),
    INSERT_OVERDUE_FAIL("PCL201076", "保存逾期清单失败"),
    DELETE_OVERDUE_FAIL("PCL201077", "删除逾期清单失败"),
    COLLECTOR_STAFF_ID_ISNULL("PCL201078", "催收人不能为空"),
    INSERT_OVERDUE_COLLECT_TASK_FAIL("PCL201079", "增加逾期催收待办任务失败"),
    DISTRIBUTE_COLLECT_TASK_FAIL("PCL201080", "分配外勤失败"),
    DISTRIBUTE_COLLECT_ISNULL("PCL201081", "分配外勤信息不能为空"),
    POSTBANKCARD_NOT_FOUND("PCL201082", "未找到寄卡信息"),
    UPDATE_REPAYACCOUNT_FAIL("PCL201083", "保存还款信用卡信息失败"),
    /*--------- 201开头表示产品模板类错误 ---------*/
    PRODUCT_TEMPLATE_NOT_EXIST("PCL201001", "金融产品模版不存在"),
    PRODUCT_TEMPLATE_ALREADY_EXISTED("PCL201002", "金融产品模版已存在"),
    PRODUCT_TEMPLATE_CREATE_FAIL("PCL201003", "金融产品模版创建失败"),
    PRODUCT_TEMPLATE_ID_ERROR("PCL201004", "产品模版编号异常"),
    PRODUCT_TEMPLATE_NOT_ALLOW_DELETE("PCL201005", "非失效的产品模版不允许删除"),
      /*--------- 202开头表示产品实例类错误 ---------*/

    /*--------- 203开头表示产品配置项类错误 ---------*/
    CONF_ITEM_NOT_EXIST("PCL203001", "金融产品配置项不存在"),

    // 2031开头表示产品配置实例相关错误
    CONF_INST_NOT_EXIST("PCL203101", "金融产品配置项实例不存在"),
    CONF_INST_CONTENT_TRANSFER_EXCEPTION("PCL205102", "金融产品配置项实例内容转换异常"),
    CONF_INST_CREATE_FAIL("PCL203103", "金融产品配置项实例创建失败"),
    CONF_TYPE_ERROR("PCL203104", "金融产品配置项类型异常"),
    CONF_INST_RANGE_CREATE_FAIL("PCL203105", "金融产品配置项实例使用范围创建失败"),
    CONF_INST_RANGE_EXIST("PCL203106", "金融产品配置项实例适用范围已存在"),
    CONF_INST_RANGE_NOT_EXIST("PCL203107", "金融产品配置项实例适用范围不存在"),
    CONF_INST_UPDATE_FAIL("PCL203108", "金融产品配置项实例更新失败"),

    // 2032开头表示产品配置实例-准入条件相关错误
    ACCESS_CONDITION_NOT_EXIST("PCL203201", "准入条件不存在"),
    ACCESS_CONDITION_QUERY_EXCEPTION("PCL203202", "查询金融产品准入条件异常"),


    //3011开头表示工作流相关错误
    WITHDRAW_ERROR("FPC301101", "撤回申请错误"),
    CANCEL_ERROR("FPC301102", "作废申请错误"),
    AUDIT_ERROR("FPC301103", "提交审核错误"),
    APPLY_ERROR("FPC301104", "提交申请错误"),
    CANCEL_PROCESS("FPC301105", "关闭流程组件失败，工作流关闭异常"),
    FLOW_INST_CREATE_FAIL("FPC301106", "流程配置项实例创建失败"),
    TASK_HAS_HANDLE("FPC301107", "任务已被提交"),
    // LOANAPPLY_SUCCESS("FPC301111","贷款申请成功"),
    LOANAPPLY_ERROR("FPC301111", "贷款申请错误"),
    // PAYMENTAPPLY_SUCCESS("FPC301113","打款申请成功"),
    PAYMENTAPPLY_ERROR("FPC301112", "打款申请错误"),
    UPDATEAPPLY_ERROR("FPC301113", "修改申请错误"),
    ACCOMAPPLY_ERROR("FPC301113", "通融申请错误"),


    SALESMANAGER_LIST_ERROR("FPC301114","业务经理列表查询失败"),
    AUDITOR_LIST_ERROR("FPC301115","审核员列表查询失败"),
    OTHER_LIST_ERROR("FPC301116","执行人列表查询失败"),
    SALESMANAGER_AUDITQUOTA_EMPTY("FPC301117","业务经理额度为空"),

    RESETLOANAPPLY_ERROR("FPC301124", "重新发起申请失败"),
    EXISTSAMEAPPLY("FPC301125", "存在相同订单的申请，无法再次发起申请"),
    EXECUTOR_ERROR("FPC301126", "无法获取执行人，请确认执行人是否存在"),

    WANDERRULERERROR("FPC301198", "处于飘红状态，无法发起打款申请"),
    APPLYSTATUSERROR("FPC301199", "订单状态无效，无法发起申请"),
    // 2033开头表示产品配置实例-产品周期相关错误

    // 2034开头表示产品配置实例-展期相关错误

    // 2035开头表示产品配置实例-逾期相关错误

    // 2036开头表示产品配置实例-资方相关错误

    // 2037开头表示产品配置实例-仓库相关错误
    WAREHOUSE_NOT_EXISTS("PCL203701", "可用仓库不存在"),

    WAREHOUSE_CONF_NOT_EXISTS("PCL203702", "未配置可用仓库"),

    // 2038开头表示产品配置实例-最低保证金比例相关错误
    MARGIN_RATE_NOT_EXIST("PCL203801", "最低保证金率不存在"),

    // 2039开头表示产品配置实例-最高质押比例相关错误

    // 2040开头表示产品配置实例-工作流相关错误

    /*--------- 210开头表示外部系统错误 ---------*/
    // 2101开头表示经销商（客户）类的错误
    DEALER_NOT_EXISTS("PCL210101", "客户不存在"),

    DEALER_AREA_NOT_EXISTS("PCL210102", "客户地区信息不存在"),

    ONLY_FOR_SPECIAL_DEALER("PCL210103", "该产品仅对特设用户开放");

    private String errMsg;
    private String errCode;

    ErrorCodeEnum(String errCode, String errMsg) {
        this.errMsg = errMsg;
        this.errCode = errCode;
    }

    /**
     * 根据类型值获取相应的枚举类
     *
     * @param code
     * @return
     */
    public static ErrorCodeEnum getErrorCodeEnum(String code) {
        for (ErrorCodeEnum c : ErrorCodeEnum.values()) {
            if (c.getErrCode().equals(code)) {
                return c;
            }
        }

        return null;
    }

    @Override
    public String toString() {
        return errCode + ": " + errMsg;
    }

    public String getErrCode() {
        return errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }
}

